package com.example.mybaties.testone.bean_process;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;

import java.beans.PropertyDescriptor;

public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {

    private Logger logger = LogManager.getLogger(this.getClass());

    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
        if("car".equals(beanName)){
            logger.debug("MyInstantiationAwareBeanPostProcessor..........postProcessBeforeInstantiation()");
        }
        return super.postProcessBeforeInstantiation(beanClass, beanName);
    }

    @Override
    public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
        if("car".equals(beanName)){
            logger.debug("MyInstantiationAwareBeanPostProcessor..........postProcessAfterInstantiation()");
        }
        return super.postProcessAfterInstantiation(bean, beanName);
    }

    @Override
    public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) throws BeansException {
        if("car".equals(beanName)){
            logger.debug("MyInstantiationAwareBeanPostProcessor..........postProcessProperties()");
        }
        return super.postProcessProperties(pvs, bean, beanName);
    }
}
